Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend:webhook-deliveries #364

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

admirsaheta
Copy link

@admirsaheta admirsaheta commented Aug 29, 2024

WHY are these changes introduced?

Fixes #362

This pull request addresses the lack of support for specifying fields and metafieldNamespaces in webhook registrations.
The feature aligns with the Ruby implementation by allowing more granular control over which fields and metafields are included
in the webhook payload.

WHAT is this pull request doing?

  • Adds support for specifying fields and metafieldNamespaces in the buildRegisterQuery method of the Registry class.
  • Updates the buildRegisterQuery method to construct GraphQL mutations with these new parameters.
  • Ensures the new parameters are properly handled and included in the mutation query string.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above
  • I have added/updated tests for this change
  • I have updated the documentation for public APIs from the library (if applicable)

Copy link
Contributor

@lizkenyon lizkenyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there 👋

Thanks for your contribution!

We will need to keep the functionality were the webhook subscription is either created or updated, and we will need to use the getMutationName so that we call the correct mutation based on the type of subscription we are creating (pubsub, http ect).

We should also update the tests to include these new parameters.

src/Webhooks/DeliveryMethod.php Outdated Show resolved Hide resolved
src/Webhooks/Registry.php Show resolved Hide resolved
@admirsaheta
Copy link
Author

Should be good now, also updated php-docs @lizkenyon

@lizkenyon
Copy link
Contributor

@admirsaheta You will need to update the tests for the register method now that we have changed the request to create the subscriptions.

@admirsaheta
Copy link
Author

Not really well-versed with tests, would appreciate co-authoring here. :)

$fieldsQuery = !empty($fields) ? 'fields: [' . implode(',', $fields) . ']' : '';
$metafieldNamespacesQuery = !empty($metafieldNamespaces) ? 'metafieldNamespaces: [' . implode(',', $metafieldNamespaces) . ']' : '';

// Assemble the webhook subscription arguments
$webhookSubscriptionArgs = $this->queryEndpoint($callbackAddress);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use this method to properly build the callback URL, for each of the webhook cases Pubsub, HTTP, eventbridge.

@lizkenyon
Copy link
Contributor

Not really well-versed with tests, would appreciate co-authoring here. :)

To run the tests you can run composer test your tests are failing because they are expecting to receive a specific GraphQL query.

@DevMahix
Copy link

DevMahix commented Oct 2, 2024

"I have signed the CLA!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants